//
//  SQLiteHelperExtend.h
//  Etion
//
//  Created by  user on 11-8-31.
//  Copyright 2011 GuangZhouXuanWu. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "XMSSQLiteHelper.h"

#import "XMSStringKv.h"

typedef NS_ENUM(NSUInteger,ESQLKvVarType)
{
    ESQLKvVarTypeNull = 0,
    ESQLKvVarTypeInt = 1,
    ESQLKvVarTypeDouble = 2,
    ESQLKvVarTypeString = 3,
    ESQLKvVarTypeGUID = 4,
    ESQLKvVarTypeDateTime = 5,
    ESQLKvVarTypeBytes = 6,
    ESQLKvVarTypeArray = 7,
    ESQLKvVarTypeDictionary = 8,
};

@interface CSQLKv : XMSStringKv
{
    ESQLKvVarType _SQLkvVarType;
}

@property(nonatomic, assign) ESQLKvVarType SQLkvVarType;

+ (id)SQLkvWithKey:(NSString *)szKey value:(NSObject *)objvalue type:(ESQLKvVarType)type;

@end


@interface XMSSQLiteHelper (SQLiteHelperExtend)

- (void)putField:(NSArray *)arKv;

- (NSString *)mergeSelectSQL:(NSArray *)arTablename kv:(NSArray *)arKv condition:(NSString *)szCondition;

- (void)prepareSelect:(NSArray *)arTablename kv:(NSArray *)arKv condition:(NSString *)szCondition;

- (NSInteger)selectTable:(NSArray *)arTablename kv:(NSArray *)arKv condition:(NSString *)szCondition gettingTable:(void (^)())gettable;

- (NSInteger)selectTable:(NSArray *)arTablename cls:(Class)cls kv:(XMSQueueDictionary *)qdKv condition:(NSString *)szCondition completion:(void (^)(NSArray *arList))completion;

- (NSInteger)selectTable:(Class)cls kv:(XMSQueueDictionary *)qdKv SQL:(NSString *)szSQL completion:(void (^)(NSArray *arList))completion;

- (NSString *)mergeInsertSQL:(NSString *)szTablename kv:(NSArray *)arKv;

//废弃
- (void)prepareInsert:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSInteger)runInsert:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSString *)mergeInsertOrIgnoreSQL:(NSString *)szTablename kv:(NSArray *)arKv;

//废弃
- (void)prepareInsertOrIgnore:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSInteger)runInsertOrIgnore:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSString *)mergeUpdateSQL:(NSString *)szTablename valueKv:(NSArray *)arKv1 conditionKv:(NSArray *)arKv2;

//废弃
- (void)prepareUpdate:(NSString *)szTablename valueKv:(NSArray *)arKv1 conditionKv:(NSArray *)arKv2;

- (NSInteger)runUpdate:(NSString *)szTablename valueKv:(NSArray *)arKv1 conditionKv:(NSArray *)arKv2;

- (NSString *)mergeDeleteSQL:(NSString *)szTablename kv:(NSArray *)arKv;

//废弃
- (void)prepareDelete:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSInteger)runDelete:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSInteger)runDelete:(NSString *)szTablename;

- (NSInteger)runDelete:(NSString *)szTablename condition:(NSString*)condition;

- (NSString *)mergeRelpace:(NSString *)szTalbename kv:(NSArray *)arkv;

//废弃
- (void)prepareReplace:(NSString *)szTablename kv:(NSArray *)arKv;

- (NSInteger)runReplace:(NSString *)szTablename kv:(NSArray *)arKv;

//- (void)PrepareUpdateOrInsertIgnore:(NSString *)szTablename value:(NSArray *)arValue condition:(NSArray *)arCondition;

- (NSInteger)runUpdateOrInsertIgnore:(NSString *)szTablename valueKv:(NSArray *)arValue conditionKv:(NSArray *)arCondition;

- (BOOL)table:(NSString*)tableName containDataWithCondition:(NSString*)condition;

- (NSArray *)mergeSQLKv:(XMSQueueDictionary *)qdTableheadkv SQLKv:(XMSQueueDictionary *)qdSqlkv;

- (NSArray *)mergeSQLKv:(XMSQueueDictionary *)qdSqlkv;

- (NSInteger)runSelectSQL:(NSString*)sql withCls:(Class)cls completion:(void (^)(NSArray *arList))completion;

- (XMSQueueDictionary *)getTableColsAndType:(NSString *)tableName;

@end
